package com.bbx.demo.thrift;

import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;

@Slf4j
public class ThriftClient {

    public static void main (String [] args) throws TException {
        TFramedTransport tFramedTransport = new TFramedTransport(new TSocket("192.168.2.252", 8095));
        TCompactProtocol tCompactProtocol = new TCompactProtocol(tFramedTransport);
        MessageService.Client client = new MessageService.Client(tCompactProtocol);
        try {
            tFramedTransport.open();
            client.ping();
            Message message = client.getMessageById(22);
            log.info("id[{}]", message.getId());
            log.info("age[{}]", message.getAge());
            log.info("name[{}]", message.getName());
        } finally {
            tFramedTransport.close();
        }
    }
}
